﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:m="clr-namespace:Signum.Windows"
    xmlns:dq="clr-namespace:Signum.Entities.DynamicQuery;assembly=Signum.Entities"
	mc:Ignorable="d"
	x:Class="Signum.Windows.FilterBuilder"
	x:Name="me">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid x:Name="filtros">
        <TextBlock Visibility="{Binding Filters.Count,  Converter={x:Static m:Converters.ZeroToVisibility}, ElementName=me}" Text="{m:Loc NoFiltersSpecified}" Margin="8"/>
        <StackPanel Grid.IsSharedSizeScope="True" Visibility="{Binding Filters.Count,  Converter={x:Static m:Converters.NotZeroToVisibility}, ElementName=me}">
            <Grid>
                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30"  SharedSizeGroup="GrColEliminar"/>
                        <ColumnDefinition  MinWidth="70" Width="Auto" SharedSizeGroup="GrColField"/>
                        <ColumnDefinition  MinWidth="70" Width="Auto" SharedSizeGroup="GrColOperation"/>
                        <ColumnDefinition  MinWidth="200" Width="Auto" SharedSizeGroup="GrColValue"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Label Grid.Row="0" Grid.Column="1" Content="{m:Loc Field}" FontWeight="Bold"/>
                    <Label Grid.Row="0" Grid.Column="2" Content="{m:Loc Operation}" FontWeight="Bold"/>
                    <Label Grid.Row="0" Grid.Column="3" Content="{m:Loc Value}" FontWeight="Bold"/>
                </Grid>
            </Grid>
            <ItemsControl 
                      x:Name="lvFilters" 
                      m:Common.LabelVisible="False" 
                      AllowDrop="True"
                      ItemsSource="{Binding Filters, ElementName=me}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <m:FilterLine Remove="filterRemove_Click" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
    </Grid>
</UserControl>